/*    */ package com.zimbra.cs.filter;
/*    */ 
/*    */ import org.apache.jsieve.parser.SieveNode;
/*    */ import org.apache.jsieve.parser.generated.Node;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DumpSieveTree
/*    */   extends SieveVisitor
/*    */ {
/* 28 */   private int mIndentLevel = 0;
/* 29 */   StringBuilder mBuf = new StringBuilder();
/*    */   
/*    */ 
/*    */   protected void visitAction(Node actionNode, SieveVisitor.VisitPhase phase, SieveVisitor.RuleProperties props) {}
/*    */   
/*    */ 
/*    */   protected void visitNode(Node node, SieveVisitor.VisitPhase phase, SieveVisitor.RuleProperties props)
/*    */   {
/* 37 */     if (phase == SieveVisitor.VisitPhase.begin) {
/* 38 */       indent();
/* 39 */       Object value = getValue(node);
/* 40 */       String valueClass = value == null ? "" : String.format(" (%s)", new Object[] { value.getClass().getSimpleName() });
/* 41 */       this.mBuf.append(String.format("%s, %s=%s%s\n", new Object[] { node.getClass().getSimpleName(), getName(node), value, valueClass }));
/* 42 */       this.mIndentLevel += 1;
/*    */     } else {
/* 44 */       this.mIndentLevel -= 1;
/*    */     }
/*    */   }
/*    */   
/*    */ 
/*    */   protected void visitRule(Node ruleNode, SieveVisitor.VisitPhase phase, SieveVisitor.RuleProperties props) {}
/*    */   
/*    */ 
/*    */   protected void visitTest(Node testNode, SieveVisitor.VisitPhase phase, SieveVisitor.RuleProperties props) {}
/*    */   
/*    */ 
/*    */   private String getName(Node node)
/*    */   {
/* 57 */     return ((SieveNode)node).getName();
/*    */   }
/*    */   
/*    */   private Object getValue(Node node) {
/* 61 */     return ((SieveNode)node).getValue();
/*    */   }
/*    */   
/*    */   private void indent() {
/* 65 */     for (int i = 0; i < this.mIndentLevel; i++) {
/* 66 */       this.mBuf.append(" ");
/*    */     }
/*    */   }
/*    */   
/*    */   public String toString() {
/* 71 */     return this.mBuf.toString();
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/filter/DumpSieveTree.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */